<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class Ip extends Model
{
    protected $guarded = [];

    public function informations()
    {
    	return $this->belongsToMany(Information::class);
    }

    /** [add_information 添加信息来源] */
    public function add_information($information_ids)
    {	
    	if ( ! is_array($information_ids)) {
    		$information_ids = compact('information_ids');
    	}
    	$this->informations()->sync($information_ids, false);
    }

    /** [delete_information 删除信息来源] */
    public function delete_information($information_ids)
    {	
    	if ( ! is_array($information_ids)) {
    		$information_ids = compact('information_ids');
    	}

    	$this->informations()->detach($information_ids);
    }


}
